package com.jiyongjun.component.core.model;

import lombok.Getter;

import java.io.Serializable;

/**
 * <h2></h2>
 * <h3>描述：</h3>
 *
 * @author yongjun.jyj
 * @since 2022/7/14 20:05
 */
@Getter
public class CommonResult<T> implements Serializable {
    protected boolean success;
    protected T model;
    protected String msgCode;
    protected String msgInfo;

    public static <T> CommonResult<T> success(T model) {
        CommonResult<T> result = new CommonResult<>();
        result.success = true;
        result.model = model;

        return result;
    }

    public static <T> CommonResult<T> failed(String msgCode, String msgInfo) {
        CommonResult<T> result = new CommonResult<>();
        result.success = false;
        result.msgCode = msgCode;
        result.msgInfo = msgInfo;

        return result;
    }
}
